/*
 * @Author       : Hejh(3010733382@qq.com)
 * @Version      : V1.0
 * @Date         : 2024-01-30 11:01:15
 * @Description  : 角色相关接口
 */

import type {
  RoleCreateReq,
  RolePageRes,
  RoleReq,
  RoleUpdateReq
} from '@/types/role'
import request from '@/utils/request'

// 分页查询角色接口
export const getRoleByPage = (params?: RoleReq) => {
  return request.get<RolePageRes>('/role/list', { params })
}

// 分页查询角色接口
export const getAuthRoleByPage = (params?: RoleReq) => {
  return request.get<RolePageRes>('/role/auth/list', { params })
}

// 添加角色接口
export const createRole = (data: RoleCreateReq) => {
  return request.post('/role/create', data)
}

// 更新角色接口
export const updateRole = (data: RoleUpdateReq) => {
  return request.put('/role/update', data)
}

// 角色排序接口
export const sortRole = (roleIds: string[]) => {
  return request.put('/role/sort', { roleIds })
}

// 角色删除接口
export const delRole = (roleIds: string[], picCode?: string) => {
  return request.delete('/role/delete', { data: { roleIds, picCode } })
}
